
## 安装 docker

sudo apt-get update -y

sudo apt-get remove -y docker docker-engine docker.io containerd runc docker-ce docker-ce-cli containerd.io

sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common

curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

sudo apt-key fingerprint 0EBFCD88

sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

#sudo add-apt-repository "deb [arch=arm64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

mkdir -p /cardone/docker/202206172335 && chmod -R 777 /cardone/docker/202206172335

mkdir -p /etc/docker

(
cat << 'EOF'
{
  "data-root": "/cardone/docker/202206172335",
  "registry-mirrors": [
    "https://registry.docker-cn.com",
    "https://jv79yr1i.mirror.aliyuncs.com"
  ],
  "insecure-registries": [
    "cardone:5000"
  ],
  "exec-opts": ["native.cgroupdriver=systemd"],
  "storage-driver": "overlay2",
  "storage-opts": [
    "overlay2.override_kernel_check=true"
  ],
  "experimental": true
}
EOF
) > /etc/docker/daemon.json

mkdir -p /boot/firmware

sed -i 's/$/ ipv6.disable=1 cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1/g' /boot/firmware/cmdline.txt

cat /boot/firmware/cmdline.txt

apt update -y && apt install -y docker-ce docker-ce-cli containerd.io

#systemctl stop docker

#systemctl restart docker

docker info

## WARNING: No swap limit support

### 编辑/etc/default/grub文件。
vi /etc/default/grub

### 找到GRUB_CMDLINE_LINUX=配置项，并追加“cgroup_enable=memory swapaccount=1”。如果GRUB_CMDLINE_LINUX=内有内容，切记不可删除，只需在后面追加cgroup_enable=memory swapaccount=1并用空格和前面的内容分隔开。

### 更新 grup

sudo update-grub

### 重启

reboot


sudo dhclient -r

sudo dhclient

ip addr

rm /etc/udev/rules.d/70-snap.core.rules
reboot